package ConsumerProducers;

public class ConsumerProducer {

    public static void main(String[] args) {
        Desk desk = new Desk();
        //厨师1
        Thread thread1 = new Thread(()->{
            while (true) {
                try {
                    desk.put();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        },"厨师1");
        thread1.start();

        Thread thread2 = new Thread(()->{
            while (true) {
                try {
                    desk.put();
                } catch (InterruptedException e) {
                    throw new RuntimeException();
                }
            }
        },"厨师2");
        thread2.start();

        Thread thread3 = new Thread(()->{
            while (true) {
                try {
                    desk.put();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        },"厨师3");
        thread3.start();

        Thread thread4 = new Thread(()->{
            while (true) {
                try {
                    desk.take();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        },"吃货1");
        thread4.start();

        Thread thread5 = new Thread(()->{
            while (true) {
                try {
                    desk.take();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        },"吃货2");
        thread5.start();
        
    }
}
